package org.example.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.example.mapper.DStaffMapper;
import org.example.pojo.DStaff;
import org.example.pojo.select.DStaffSelect;
import org.example.pojo.select.ExceptionStaffSelect;
import org.example.pojo.select.PendingStaffSelect;
import org.example.pojo.select.ResignStaffSelect;
import org.example.service.DStaffService;
import org.example.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@CrossOrigin(origins = "*")
@RestController
@RequestMapping("/staff")
@Tag(name = "人员数据API",description = "Staff Controller")
public class DStaffController {

    @Autowired
    private DStaffService dStaffService;

    /**
     * 搜索待入住员工信息
     * @param pendingStaffSelect 搜索条件
     * @return 搜出的员工结果
     */
    @Operation(summary = "搜索待入住员工信息")
    @PostMapping("/selectPendingStaff")
    public Result<Map>  SelectPendingStaff(@RequestBody PendingStaffSelect pendingStaffSelect){
        return dStaffService.SelectPendingStaff(pendingStaffSelect);
    }


    /**
     * 搜索员工信息
     * @param dStaffSelect 搜索条件
     * @return 搜出的员工结果
     */
    @Operation(summary = "搜索员工信息")
    @PostMapping("/selectAll")
    public Result<Map>  SelectAll(@RequestBody DStaffSelect dStaffSelect){
        return dStaffService.SelectAllStaffs(dStaffSelect);
    }

    /**
     * 搜索全部员工的简化信息
     * @return 搜出的员工结果
     */
    @Operation(summary = "搜索全部员工的简化信息")
    @PostMapping("/selectStaffInfo")
    public Result<Map>  SelectStaffInfo(@RequestBody DStaffSelect dStaffSelect){
        return dStaffService.SelectStaffInfo(dStaffSelect);
    }


    /**
     * 导出在住员工信息
     * @return 搜出导出在住员工信息
     */
    @Operation(summary = "导出在住员工信息")
    @PostMapping("/selectAllDown")
    public Result<Map>  SelectAllDown(){
        return dStaffService.SelectAllDownStaffs();
    }

    /**
     * 批量删除人员信息
     * @param dStaffList
     * @return 无
     */
    @Operation(summary = "(批量)删除人员信息")
    @PostMapping("/deleteApartmentStaffs")
    public Result<DStaff>  DeleteApartmentStaffs(@RequestBody List<DStaff> dStaffList){
        return dStaffService.DeleteApartmentStaffs(dStaffList);
    }

    /**
     * 更改宿舍中的入住人员
     * @param DStaffSelect 更改的人员
     * @return 无
     */
    @Operation(summary = "更改宿舍中的入住人员")
    @PostMapping("/addApartmentStaffs")
    public Result<DStaff>  AddApartmentStaffs(@RequestBody DStaffSelect DStaffSelect){
        return dStaffService.AddApartmentStaffs(DStaffSelect);
    }

    /**
     * 在宿人员换宿
     * @param dStaffSelect
     * @return
     */
    @Operation(summary = "在宿人员换宿")
    @PostMapping("/updateStaffApartment")
    public Result<Integer>  UpdateStaffApartment(@RequestBody DStaffSelect dStaffSelect){
        return dStaffService.UpdateStaffApartment(dStaffSelect);
    }

    /**
     * 按员工名称搜索
     * @param dStaff 员工名称
     * @return 搜索结果
     */
    @Operation(summary = "按员工名称搜索")
    @PostMapping("/selectOneByName")
    public Result<DStaff>  SelectOneByName(@RequestBody DStaff dStaff){
        return dStaffService.SelectOneByName(dStaff);
    }

    /**
     * 按员工号搜索
     * @param dStaff 携带staff_id
     * @return 搜索结果
     */
    @Operation(summary = "按员工号搜索")
    @PostMapping("/selectOneById")
    public Result<DStaff>  SelectOneById(@RequestBody DStaff dStaff){
        return dStaffService.SelectOneById(dStaff);
    }

    /**
     * 新增员工
     * @param dStaffSelect 添加的批量员工
     * @return 无
     */
    @Operation(summary = "新增员工")
    @PostMapping("/addStaffs")
    public Result<DStaff>  AddStaffs(@RequestBody DStaffSelect dStaffSelect){
        return dStaffService.AddStaffs(dStaffSelect);
    }

    /**
     * 实际删除人员
     * @param dStaff 删除实际人员
     * @return 无
     */
    @Operation(summary = "实际删除人员")
    @PostMapping("/deleteStaff")
    public Result<DStaff> DeleteStaff(@RequestBody DStaff dStaff){
        return dStaffService.DeleteStaff(dStaff);
    }

    /**
     * 修改人员信息
     * @param dStaff 修改的人员信息
     * @return 无
     */
    @Operation(summary = "删除实际人员")
    @PostMapping("/updateStaff")
    public Result<DStaff> UpdateStaff(@RequestBody DStaff dStaff){
        return dStaffService.UpdateStaff(dStaff);
    }


    /**
     * 删除员工
     * @param DStaff 删除的员工
     * @return 无
     */
    @Operation(summary = "删除员工")
    @PostMapping("/updateStaffStatus")
    public Result<DStaff>  UpdateStaffStatus(@RequestBody DStaff DStaff){
        return dStaffService.UpdateStaffStatus(DStaff);
    }

    /**
     * 搜索人员电话信息
     * @param DStaff 人员staff_id
     * @return 对应人员的电话信息
     */
    @Operation(summary = "搜索人员电话信息")
    @PostMapping("/selectStaffPhoneNumber")
    public Result<Map>  selectStaffPhoneNumber(@RequestBody DStaff DStaff){
        return dStaffService.selectStaffPhoneNumber(DStaff);
    }


    /**
     * 将待入住人员，加入到入住人员
     * @param dStaffSelect 待入住人员
     */
    @Operation(summary = "将待入住人员，加入到入住人员")
    @PostMapping("/addPendingStaff")
    public Result<Map>  AddPendingStaff(@RequestBody DStaffSelect dStaffSelect){
        return dStaffService.AddPendingStaff(dStaffSelect);
    }

    /**
     * 查询待离职和退宿人员
     * @param resignStaffSelect 待入住人员
     */
    @Operation(summary = "查询待离职和退宿人员")
    @PostMapping("/selectResignStaff")
    public Result<Map>  SelectResignStaff(@RequestBody ResignStaffSelect resignStaffSelect){
        return dStaffService.SelectResignStaff(resignStaffSelect);
    }

    /**
     * 退宿操作
     * @param resignStaffSelect 待入住人员
     */
    @Operation(summary = "退宿操作")
    @PostMapping("/deleteResignStaff")
    public Result<Map>  DeleteResignStaff(@RequestBody ResignStaffSelect resignStaffSelect){
        return dStaffService.DeleteResignStaff(resignStaffSelect);
    }

    /**
     * 退宿操作
     * @param exceptionStaffSelect 待入住人员
     */
    @Operation(summary = "退宿操作")
    @PostMapping("/selectExceptionStaff")
    public Result<Map>  SelectExceptionStaff(@RequestBody ExceptionStaffSelect exceptionStaffSelect){
        return dStaffService.SelectExceptionStaff(exceptionStaffSelect);
    }


    /**
     * 查询待离宿总人数
     */
    @Operation(summary = "查询待离宿总人数")
    @PostMapping("/exception_resignStaffCount")
    public Result<Integer>  exception_resignStaffCount(){
        return dStaffService.exception_resignStaffCount();
    }

    /**
     * 查询待入住人员总人数
     */
    @Operation(summary = "查询待入住人员总人数")
    @PostMapping("/pending_staffCount")
    public Result<Integer> pending_staffCount(){
        return dStaffService.pending_staffCount();
    }


}
